package ACM.meituan;

/**
 * @Author wwk
 * @DATE 2022/8/20 10:05
 */
import  java.util.*;
public class second {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();   //[1,n]
        int[] loc1 = new int[2];
        int[] loc2 = new int[2];
        int[] loc3 = new int[2];
        int[] distance = new int[3];
        for(int i = 0; i < 4; i++){
            if(i==0){
                for(int j = 0; j <2; j++){
                    loc1[j] = scanner.nextInt();
                }
            }else if(i==1){
                for(int j = 0; j <2; j++){
                    loc2[j] = scanner.nextInt();
                }
            }else if(i==2){
                for(int j = 0; j <2; j++){
                    loc3[j] = scanner.nextInt();
                }
            }else{
                for(int j = 0; j < 3; j++){
                    distance[j] = scanner.nextInt();
                }
            }
        }
        ArrayList<int[]> rets = new ArrayList<>();
        for (int i = 1; i <= 3; i++) {
            for(int j = 1; j <= 3; j++){
                if(Math.abs(loc1[0]-i) + Math.abs(loc1[1]-j) == distance[0] && (Math.abs(loc2[0]-i) + Math.abs(loc2[1]-j) == distance[1]
                && (Math.abs(loc3[0]-i) + Math.abs(loc3[1]-j) == distance[2]))){
                    rets.add(new int[]{i,j});
                }
            }
        }
//        for (int[] ret : rets) {
//            System.out.println(Arrays.toString(ret));
//        }
        Collections.sort(rets,(o1, o2) -> o1[0]-o2[0]);
        Collections.sort(rets,(o1, o2) -> o1[0] == o2[0] ? o1[1]-o2[1] : o1[0]-o2[0]  );
        for (int i : rets.get(0)) {
            System.out.print(i+" ");

        }
    }





}
